package sgt;

import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;

public class Test2 {
    public static void main(String[] args) {
//        Map<String,Integer[]> map = new HashMap<>();
//        Integer []a=new Integer[]{1,2,3};
//        map.put("1",a);
//        System.out.println(Arrays.deepToString(a));
//        Integer[] b =map.get("1");
//        System.out.println(Arrays.deepToString(b));
//        int []a=new int[10];
//        for (int p:a){
//            System.out.println(p);
//        }
        ProductCart []productCarts=new ProductCart[10];
        for (int i = 0; i < 10; i++) {
            productCarts[i]=new ProductCart(i+"",10-i);
            System.out.println(productCarts[i].product_id+" "+productCarts[i].cart_num);
        }
        Arrays.sort(productCarts, new Comparator<ProductCart>() {
            @Override
            public int compare(ProductCart o1, ProductCart o2) {
                if (o1.cart_num> o2.cart_num) {
                    return 1;
                }else {
                    return -1;
                }
            }
        });
        for (int i = 0; i < 10; i++) {
            Arrays.deepToString(productCarts);
//            System.out.println(productCarts[i].product_id+"1 "+productCarts[i].cart_num);
        }
    }
    static class ProductCart{
        public ProductCart(String product_id, int cart_num) {
            this.product_id = product_id;
            this.cart_num = cart_num;
        }

        String product_id;
        int cart_num;
    }

}
